<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>修改文章</title>
<link href="<%=path%>/static/usercss/css/all.css?ehweee43w3" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=path%>/static/js/jquery-3.2.1.js"></script>
<jsp:include page="/WEB-INF/web/includ/header.jsp"></jsp:include>

<!-- 编辑器样式 -->
<style type="text/css">
	#editor{
		width:580px;
	}

</style>

<body>

<section>
<div class="wrap">
  <div id="seach">
    <div id="logo"><a href="http://fenlicx.qinglab.cn" title="垃圾分类查询">分类查询</a></div>
    <div class="seach">
      <input type="text" name="seach" class="seach_txt" id="seach">
      <input type="submit" class="seach_bun" name="button" id="button" value="查询分类">
    </div>
  </div>
  
  <div class="section">
  <article id="datalist">
      <nav>
        <%-- <div class="seach">
       <form action="<%=path%>/web/question/addQ" method="post">
        <input name="classification" type="text"  aria-label="输入垃圾" placeholder="输入垃圾" autocapitalize="off">
    		<a href="javascript:void(0);" id="piPei">匹配分类</a>
    	</form>
        </div> --%>
        <!-- <div class="msg">
          推荐分类 <a href="#">创建新的分类及名称</a>
        </div> -->
        <div id="breadcrumb">
 
      </div>
    </nav>
      <div id="title">
      <h1>修改文章</h1>
      <label>分类名称</label>
    </div>
  <datalist id="dataList">
	<form id="f1" action="<%=path%>/web/userinfo/compileArticle" method="post">
		<dl>
	        <dt>分类名称</dt>
	        <dd><input value="${requestScope.rubbish.id }" id="rubbishId" type="hidden" name="rubbish.id" ">
	       
	        <input disabled="disabled" value="${requestScope.rubbish.name }" id="rubbishName" type="text" aria-label="系统匹配废弃物名称" placeholder="系统匹配废弃物名称"></dd>
	        <input type="hidden" value="${requestScope.article.id}" name="id">
     	</dl>
    	 <dl>
      		<dt>文章标题</dt>
	      	<dd><input value="${requestScope.article.title }" id="articleTitle" name="title" type="text"/></dd>
    	</dl>
    	<dl>
      		<dt>文章来源</dt>
	      	<dd><input value="${requestScope.article.source }" id="source" name="source" type="text" placeholder="原创或其他网站"/></dd>
    	</dl>
      	<dl>
      		<dt>文章内容</dt>
	      	<dd><script id="editor" type="text/plain" name="content"></script> </dd>
    	</dl>
     
	    <div class="submit">
	    	<div style="color:gray;font-size:12px;">提交后，两小时内可前往个人中心修改</div><br>
	         <input type="submit" id="sub" value="确认修改">
	         <input type="button" id="back" value="重置">
	     </div>
      </form>
  </datalist>
  </article>
  <jsp:include page="/WEB-INF/web/includ/aside.jsp"></jsp:include>
</div>
</div>
</section>

</body>
<jsp:include page="/WEB-INF/web/includ/footer.jsp"></jsp:include>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/ueditor/1.4.3/ueditor.config.js?123123"></script>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/ueditor/1.4.3/ueditor.all.js"> </script>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script> 
<script type="text/javascript">
$(function(){
	var path = "${pageContext.request.contextPath}"
	
	var ue = UE.getEditor('editor',{toolbars:[['simpleupload','bold','italic','forecolor','strikethrough','horizontal','selectall','time','date','help']],										
		elementPathEnabled:false,
		wordCount:false});
	
	ue.addListener("ready",function(){
		ue.setContent('${requestScope.article.content}');
	});
	
	$("#sub").click(function(){
		var rubbishName = $("#rubbishName").val();
		var title = $("#articleTitle").val();
		var source = $("#source").val();
		var content = ue.getContent();;
		//alert(rubbishName+","+title+","+source+","+content);
		if(rubbishName!=""&&title!=""&&source!=""&&content!=""){
			$("#f1").submit();
		}else{
			layer.alert("请将所需内容补充完整");	
		}
	});
	
});


</script>

<!-- <script type="text/javascript">
var msg ="${param.msg}";

if(msg=='succ'){
	
	layer.alert("提交成功");	
}
if(msg=='Num'){
	
	layer.alert("数量格式不对！");
}
</script> -->
<script type="text/javascript">
	function accept(id) {
		
		$.post("<%=path%>/web/article/using",
				{id:id},
				function(mes){
					$("#rubbishName").empty();
					$("#rubbishName").val(mes);
					$("#rubbishId").val(id);
		});
	}
			
	
	$(function() {
		$("#piPei").click(function() {
				var seachData = $(this).prev().val();				
				$.ajax({
					type:'post',
					url:'<%=path%>/web/userinfo/seachData',
					data:{seachData:seachData},
					success:function(mes){
						 var json = eval(mes); //数组    
						 var i = 0;
             $.each(json, function (index, item) {
                 //循环获取数据  
                 if(i>2){
                	 return;
                 }
                 var id = json[index].id;                
									
                 var str1 ="<ul><li><a href=\"javascript:void(0);\">"+json[index].secondtype.firsttype.title+"</a><span>&gt;</span></li>";
                 var str2 = "<li><a href=\"javascript:void(0);\">"+json[index].secondtype.title+"</a><span>&gt;</span></li>"
                 var str3 = "<li><a href=\"javascript:void(0);\">"+json[index].name+"</a></li><li onclick=\"accept("+json[index].id+")\"><a  href=\"javascript:void(0);\">采用</a></li></ul>"    
                 var str = str1+str2+str3;    
                 var rubbish = $(str); 
                 $("#breadcrumb").append(rubbish);
                 i++;
              });
					}
				});

		});
	});
	
	$("#back").click(function() {
		
		$("#rubbishName").val("");
		$("#articleTitle").val("");
		$("#source").val("");
	})

</script>
</html>
